package pe.gob.mintra.trabajadoreshogar.daoimpl;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.log4j.Logger;

import pe.gob.mintra.trabajadoreshogar.action.CalculoCtsAction;
import pe.gob.mintra.trabajadoreshogar.bean.Cts;
import pe.gob.mintra.trabajadoreshogar.dao.CtsDAO;
import pe.gob.mintra.trabajadoreshogar.factory.MyBatisConnectionFactory;

public class CtsDAOImp implements CtsDAO {
	
	private final static Logger logCtsDAOImp = Logger.getLogger(CtsDAOImp.class);
	
	private SqlSessionFactory sqlSessionFactory;

	public CtsDAOImp() {
		sqlSessionFactory = MyBatisConnectionFactory.getSqlSessionFactory();
	}
	

	@Override
	public void insertarCts(Cts objCts){
		
		SqlSession session = sqlSessionFactory.openSession();

		try {
			
			session.insert("Cts.insertarCts",objCts);
		} 
		catch(Exception ex){
			session.rollback();
			logCtsDAOImp.error(ex.getMessage());
		}
		finally {
			session.close();
		}

	}

}
